package com.zking.web.TL;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.zking.dao.domain.ProfitMonth;
import com.zking.service.impl.PayServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * @author Tanglei
 * @date 2020/8/22 - 10:05
 */
@Controller
@RequestMapping(value = "/pay",name = "支付")
public class PayController {

    @Autowired
    PayServiceImpl payService;

    @RequestMapping(value = "/profitMonthly",name = "收入按月统计")
    @ResponseBody
    public String getProfitMonthly(){
        List<ProfitMonth> profitMonths = payService.queryAmountMonthly();
        JSONArray dataStr= JSONArray.parseArray(JSON.toJSONString(profitMonths));
        return dataStr.toString();
    }

    @RequestMapping(value = "/getTotalProfit",name = "获取总收益")
    @ResponseBody
    public Double getTotalProfit(){
        return payService.payAmountTotal();
    }
}
